/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-01-12 09:35:49
 * @LastEditTime : 2023-07-19 15:19:39
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\TwoRouter\Form.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, DelDataButton, AnnexButton } from '../Common/options'

export const Form = async ({ OptionsEvent, oneData }) => {
    let data = {
        pageSize: 10,
        hideInSearch: true,
        params: { formUuid: oneData.uuid },
        initialValues: { formUuid: oneData.uuid },
        get: API_LIST()['getFormDetail'],
        added: 'posFormDetail',
        options: [
            oneData.approvalStatus === 0 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'formUuid',
                title: 'formUuid',
                valueType: 'hidden',
                hideInTable: true,
            },
            {
                dataIndex: 'originalName',
                title: '原始文件名',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'attachmentUuid',
                title: '附件',
                valueType: 'upload',
                valueFile: [1, 2, 3, 4, 5],
                fileUrl: 'fileUrl',
                rules: true,
                hideInSearch: true,
                hideInTable: true,
            },
            {
                dataIndex: 'fileUrl',
                title: '视频附件',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
                width: 400,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 220,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid, fileUrl } = record
                    return [
                        fileUrl && <AnnexButton OptionsEvent={OptionsEvent} key="see" url={fileUrl} title="查看附件" />,

                        oneData.approvalStatus === 0 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url="FormDetail"
                                uuid={uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
